package cn.j3code.demo1liyineng;

import cn.j3code.demo1liyineng.ClassroomMapper;
import cn.j3code.demo1liyineng.Classroom;
import cn.j3code.demo1liyineng.ClassroomService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassroomServiceImpl extends ServiceImpl<ClassroomMapper, Classroom> implements ClassroomService {

    private final ClassroomMapper classroomMapper;

    public ClassroomServiceImpl(ClassroomMapper classroomMapper) {
        this.classroomMapper = classroomMapper;
    }

    @Override
    public List<Classroom> getAllClassrooms() {
        return classroomMapper.selectList(null);
    }

    @Override
    public Classroom getClassroomById(Long id) {
        return classroomMapper.selectById(id);
    }

    @Override
    public void addClassroom(Classroom classroom) {
        classroomMapper.insert(classroom);
    }

    @Override
    public void updateClassroom(Classroom classroom) {
        classroomMapper.updateById(classroom);
    }

    @Override
    public void deleteClassroom(Long id) {
        classroomMapper.deleteById(id);
    }
}
